package com.ecommerce.dal.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.ecommerce.dal.dao.IClientHistoryDAO;
import com.ecommerce.dal.entity.ClientHistory;
import com.ecommerce.dal.util.CustomHibernateDAOSupport;


@Repository("clientHistoryDAO")
public class ClientHistoryDAO extends CustomHibernateDAOSupport implements IClientHistoryDAO {

	@Override
	public void save(ClientHistory clientHistory) {
		getHibernateTemplate().save(clientHistory);
		
	}
//
//	@Override
//	public void update(ClientHistory clientHistory) {
//		getHibernateTemplate().update(clientHistory);
//		
//	}
//
//	@Override
//	public void delete(ClientHistory clientHistory) {
//		getHibernateTemplate().delete(clientHistory);
//		
//	}

	@Override
	public List<ClientHistory> findByClientId(long clientId) {
		List list = getHibernateTemplate().find("select clientHistory from ClientHistory clientHistory inner join clientHistory.client client inner join client.user user where user.userId=?",clientId);
		return ((list != null && list.size()>0) ?  list : null) ;
	}

	@Override
	public List<ClientHistory> findByClientUserName(String clientUserName) {
		List list = getHibernateTemplate().find("select clientHistory from ClientHistory clientHistory inner join clientHistory.client client inner join client.user user where user.userName=?",clientUserName);
		return ((list != null && list.size()>0) ?  list : null) ;
	}

}
